package com.diver.flinkdemo.mapper.mysqlMapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.diver.flinkdemo.dto.xxt.StudentCartManageDto;
import com.diver.flinkdemo.dto.xxt.UpdateModeDto;
import com.diver.flinkdemo.entity.xxt.StudentCard;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * Created by wenjun on 2018/7/5.
 */
public interface StudentCardMapper extends BaseMapper<StudentCard> {

    List<StudentCard> findBindStuCardInfo(@Param("userId") String userId, @Param("cardTypes") List<String> cardTypes);

    List<StudentCard> findBindStuCardInfoByStudentCardId(@Param("studentCardId") String studentCardId);

    @Select("select id,school_name,grade_id,grade_name,school_id,class_name from student_card where grade_id = #{gradeId}")
    List<StudentCard> getStudentCardByGradeId(String gradeId);

    Long queryCountCustomer(Map<String, Object> params);

    List<StudentCartManageDto> queryListCustomer(@Param("studentCardIds") List<String> studentCardIds,
                                                 @Param("isGuardTime") Integer isGuardTime);

    /**
     * 根据有上报时间查询
     *
     * @param params
     * @return
     */
    List<StudentCartManageDto> queryListCustomerOne(Map<String, Object> params);

    /**
     * 根据无上报时间查询
     *
     * @param params
     * @return
     */
    List<StudentCartManageDto> queryListCustomerTwo(Map<String, Object> params);

    List<String> queryListCustomerAll(Map<String, Object> params);

    List<String> queryTPListCustomerAll(Map<String, Object> params);

    @Update("update student_card set school_name = #{schoolName} where school_id = #{schoolId}")
    int updateSchoolName(@Param("schoolId") String schoolId, @Param("schoolName") String schoolName);

    @Update("update student_card set epay_register_status = #{status} where id = #{id}")
    int updateSchoolPayEasStatus(@Param("id") String schoolId, @Param("status") String status);

    int updateHjyStudentCard(StudentCard studentCard);

    /**
     * 更新黄石工行会员码
     *
     * @param studentCard
     * @return
     */
    @Update("update student_card set member_phone= #{memberPhone}, member_code = #{memberCode} where imei = #{imei}")
    int updateHsghMemberCode(StudentCard studentCard);

    /**
     * 根据学校统计用户
     *
     * @param schoolNames
     * @return
     */
    int countBySchoolName(@Param("schoolNames") String[] schoolNames);

    /**
     * 分页获取用户信息列表
     *
     * @param schoolNames
     * @param startIndex
     * @param pageSize
     * @return
     */
    List<Map> PagingAcquisitionInfo(@Param("schoolNames") String[] schoolNames, @Param("startIndex") int startIndex, @Param("pageSize") int pageSize);

    /**
     * imei获取亲情号
     *
     * @param imei
     * @return
     */
    String getFamilyNumbers(@Param("imei") String imei);

    /**
     * imei获取亲情号
     *
     * @param imei
     * @return
     */
    String getCardType(@Param("imei") String imei);

    /**
     * 根据学校id获取所以绑定学生信息
     *
     * @param schoolId
     * @return
     */
    List<UpdateModeDto> getStudentBindList(String schoolId);

    List<UpdateModeDto> getStudentBindList2(String schoolId);

    /**
     * 获取学生卡证信息， iccId
     *
     * @param iccId
     * @return
     */
    StudentCard getStudentCardByIccId(String iccId);

    /**
     * 获取学生卡证信息， imei
     *
     * @param imei
     * @return
     */
    StudentCard getStudentCardByImei(String imei);

    List<StudentCard> findStudentCardsByCondition(String schoolId, String gradeId, String classId,
                                                  String cardType, String personType);

    int updateStudentCardByImei(StudentCard studentCard);

    int unbindUpdateStudentInfo(String imei);

    List<StudentCard> findBindStuCardInfoNew(@Param("phone") String phone, @Param("cardTypes") List<String> cardTypes);
}
